<?php
namespace App\Services;
use Redis,Cache,Log;

class RedisService
{
	public static function set($key,$data,$timestamp='')
	{
		
		try {
			Redis::set($key, $data);
			
		} catch(\Exception $e) {
			Log::error($e->getMessage());
		}
		return true;
			
	}

	public static function get($key)
	{
		return Redis::get($key);
	}

	

	public static function del($key)
	{
		return Redis::del($key);
	}
	
	public static function incre($key,$data)
	{
		Redis::incre($key);
	}

	public static function decre($key,$data)
	{
		Redis::decre($key);
	}

	public static function exists($key)
	{
		Redis::exists($key);
	}

	//入栈
	public static function lpush($key,$val)
	{
		Redis::lpush($key,$val);
	}

	// 出栈
	public static function lpop($key)
	{
		return Redis::lpop($key);
	}

	/**
	 * @param lng 127.909 ,lat 36.2323
	 */
	public static function geoadd($lng,$lat,$name)
	{
		return Redis::geoadd("ad:board:geo", $lng, $lat, $name);
	}

	/**
	 * @param lng 127.909 ,lat 36.2323
	 */
	public static function geodel($name)
	{
		return Redis::zrem("ad:board:geo",$name);
	}

	public static function georadius($lng,$lat,$meter=1000)
	{
		return Redis::georadius("ad:board:geo", $lng, $lat, $meter, "m", "WITHDIST", "ASC");	
	}
	
		
}
?>